from typing import List

class Solution:
    def evalRPN(self, tokens: List[str]) -> int:
        stack = []
        for token in tokens:
            if token in '+-*/':
                b = stack.pop()
                a = stack.pop()
                if token == '+':
                    c = a + b
                elif token == '-':
                    c = a - b
                elif token == '*':
                    c = a * b
                elif token == '/':
                    neg = (a < 0 < b or b < 0 < a)
                    c = abs(a) // abs(b)
                    if neg:
                        c *= -1
                stack.append(c)
            else:
                a = int(token)
                stack.append(a)
        return stack[0]


solution = Solution()
res = solution.evalRPN(["4","-2","/","2","-3","-","-"])
print(res)




